//
// Created by wyh on 2025-06-14 09:00.
//

#ifndef CPP_FRAMEWORK_MINE_VALUE_H
#define CPP_FRAMEWORK_MINE_VALUE_H

#include <string>

namespace wyh {
    namespace utility {
        class Value
        {
            enum Type
            {
                V_NULL = 0,
                V_BOOL,
                V_INT,
                V_FLOAT,
                V_DOUBLE,
                V_STRING
            };

        public:
            Value();

            Value(bool value);

            Value(int value);

            Value(unsigned int value);

            Value(float value);

            Value(double value);

            Value(char *value);

            Value(std::string value);

            void show() const;

            Value &operator=(bool value);

            Value &operator=(int value);

            Value &operator=(unsigned int value);

            Value &operator=(float value);

            Value &operator=(double value);

            Value &operator=(char *value);

            Value &operator=(std::string value);

            Type type() const;

            bool is_null() const;

            bool is_bool() const;

            bool is_int() const;

            bool is_float() const;

            bool is_double() const;

            bool is_string() const;

            bool operator==(const Value &other);
            bool operator!=(const Value &other);

            operator bool();
            operator bool() const;

            operator int();
            operator int() const;

            operator unsigned int();
            operator unsigned int() const;

            operator float();
            operator float() const;

            operator double();
            operator double() const;

            operator std::string();
            operator std::string() const;

            friend std::ostream & operator<<(std::ostream &os,const Value &value)
            {
                os<<value.m_value;
                return os;
            }

        private:
            Type m_type;
            std::string m_value;
        };
    } // namespace utility
} // namespace wyh

#endif //CPP_FRAMEWORK_MINE_VALUE_H
